// 订单详情页面 陈俊俊
<template>
  <div class="body">
    <!-- <div v-for="(item,index) in list" :key="index"> -->

    <div class="top">
      <router-link to="/order/list">
        <van-icon class="icon" name="wap-home-o" />
      </router-link>
      <span>订单详情</span>
    </div>

    <div class="content">
      <span>订单取消</span>
      <van-icon class="icon" name="after-sale" />
    </div>

    <div class="user">
      <div class="icon1">
        <van-icon name="location-o" />
      </div>
      <router-link to="/address/list">
        <div class="user-name">
          <div>
            <span>{{addressInfo.name}}</span>
            <span class="phone">{{addressInfo.phone}}</span>
          </div>
          <div>{{addressInfo.address}}</div>
        </div>
      </router-link>
    </div>

    <ul class="order">
      <li v-for="(item,index) in list.carts" :key="index">
        <img :src="item.imgUrl" alt />
        <div class="goods">
          <div class="title">{{item.masterName}}</div>
          <div class="title2">
            <div class="fs-12">
              <span>&yen;</span>
              <span>{{item.price/100}}</span>
              <span></span>
            </div>
            <div>×{{item.buyNum}}</div>
          </div>
        </div>
      </li>
    </ul>

    <div class="money">
      <div>
        <div class="money-1">商品金额</div>
        <div>
          <span class="fs-12">&yen;</span>
          <span class="fs-12">{{list.totalMoney}}</span>
        </div>
      </div>
      <div>
        <div class="money-2">运费</div>
        <div>
          <span class="fs-12">&yen;</span>
          <span class="fs-12">{{0.00}}</span>
        </div>
      </div>
      <div>
        <div class="money-3">实付</div>
        <div>
          <span class="fs-12" style="color: #be3335;line-height:22px;"></span>
          <span class="fs-12" style="color: #be3335;">&yen;{{list.totalMoney}}</span>
        </div>
      </div>
    </div>

    <div class="Numbering">
      <div style="font-size:14px;height:50px;line-height:25px;">
        <p>订单编号&nbsp;&nbsp;{{this.$dataFormat(list.createTime,'yy')}}</p>
        <p>下单时间&nbsp;&nbsp;{{this.$dataFormat(list.updateTime,'yy')}}</p>
      </div>
      <div style="height:50px;line-height:40px;font-size:15px;">
        <span>复制</span>
      </div>
    </div>

    <div class="bottom" style="font-size:15px;">
      <div>
        <van-icon name="service-o" />
      </div>
      <div>
        <span @click="again">重新购买</span>
      </div>
    </div>

    <!-- </div> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: {},
      addressInfo: {},
      carts: [],
      productId: "",
      buyNum: ""
    };
  },
  methods: {
    getList(id) {
      let url = "/order/detail?orderId=" + id;
      this.$axios
        .get(url)
        .then(res => {
          let obj = res.result;
          this.list = obj;
          // console.log(this.list);
          this.addressInfo = obj.addressInfo;
          this.productId = obj.carts[0].productId;
          this.buyNum = obj.carts[0].buyNum;
        })
        .catch(err => {
          console.log("err", err);
        });
    },
    again() {
      let url = "/cart/add";
      let data = {
        productId: this.productId,
        buyNum: this.buyNum
      };
      this.$axios
        .post(url, data)
        .then(res => {
          // console.log("res", res);
          // console.log("this.productId", this.productId);
          this.$router.push(`/order/submit/${this.productId}/${1}`);
        })
        .catch(err => {
          console.log("err", err);
        });
    }
  },
  created() {
    let id = this.$route.params.id;
    // console.log(this.id);

    this.getList(id);
  }
};
</script> 
<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.body {
  background-color: #f4f4f4;
  height: 100vh;
}
.top {
  background-color: #fff;
  position: relative;
  text-align: center;
  height: 44px;
  line-height: 44px;
  .icon {
    position: absolute;
    font-size: 22px;
    left: 5px;
    top: 9px;
  }
  span {
    margin-left: -22px;
    font-weight: 700px;
    color: #2e2f30;
    font-size: 17px;
    font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
  }
}
.content {
  background-color: #be3335;
  display: flex;
  justify-content: space-between;
  height: 75px;
  line-height: 75px;
  padding: 0 40px;
  color: #fff;
  font-weight: 700px;
  font-size: 17px;
  font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
  .icon {
    font-size: 40px;
    height: 75px;
    line-height: 75px;
  }
}
.user {
  height: 90px;
  background-color: #fff;
  display: flex;
  .icon1 {
    line-height: 90px;
    text-align: center;
    width: 60px;
    font-size: 25px;
  }
  .user-name {
    padding-top: 5px;
    div:nth-child(1) {
      padding-top: 10px;
      line-height: 21px;
      width: 100%;
      font-size: 15px;
      color: #191a1b;
      font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
      .phone {
        color: #a9acaf;
        font-size: 15px;
        margin-left: 5px;
      }
    }
    div:nth-child(2) {
      font-size: 13px;
      color: #797d82;
      width: 75vw;
      line-height: 21px;
      font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
    }
  }
}
.order {
  margin: 10px 0;
  li {
    display: flex;
    margin-bottom: 1px;
    padding: 10px;
    background-color: #fff;
    img {
      display: block;
      width: 80px;
      height: 80px;
    }
    .goods {
      margin-left: 10px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      width: 100%;
      .title {
        // overflow: hidden;
        // text-overflow: ellipsis;
        // white-space: nowrap;
        width: 250px;
        font-size: 14px;
        font-weight: 600;
        color: #797b7c;
        line-height: 22px;
      }
      .title2 {
        display: flex;
        justify-content: space-between;
        div:nth-child(1) {
          color: #be3335;
        }
        div:nth-child(2) {
          color: #bdc0c5;
          font: 12px/1.5 Tahoma, Helvetica, Arial, sans-serif;
          font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
          margin-top: 4px;
        }
      }
    }
  }
}
.fs-12 {
  margin-top: -2px;
  font-size: 13px;
  color: #c03131;
  font-family: Microsoft YaHei, Tahoma, Helvetica, Arial, sans-serif;
}
// .fs-13 {
//   font-size: 13px;
// }
.money {
  background: #fff;
  padding: 10px;
  div:nth-child(1) {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    .money-1 {
      color: #a7aaad;
    }
  }
  div:nth-child(2) {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    margin: 3px 0;
    .money-2 {
      color: #a7aaad;
    }
  }
  div:nth-child(3) {
    display: flex;
    justify-content: space-between;
    .money-3 {
      font-weight: 600;
      font-size: 15px;
    }
  }
}
.Numbering {
  background-color: #fff;
  margin: 10px 0;
  display: flex;
  justify-content: space-between;
  padding: 10px;
  div:nth-child(2) {
    padding: 5px;
    span {
      border: 1px solid;
      padding: 2px 10px;
    }
  }
}
.bottom {
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 15px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}
</style>